package com.xiaxiang.xiawan;

import android.app.Activity;
import android.content.Intent;
import android.os.Environment;
import android.util.Log;

import java.io.File;

import static com.umeng.socialize.utils.ContextUtil.getPackageName;

/**
 * Created by Administrator on 2017-10-28.
 */

public class XXConfigData {
    public static final int LOGIN_RECODE_SUCCESS = 100;
    public static final int LOGIN_RECODE_FAIL = 101;
    public static final int LOGIN_REQUEST_CODE = 1000;
    public static final String SDCARD_PATH = "";
    public static final String CACHE_PATH = "/xiaxiang/xiawan/cache/";
    public static final String TOKEN_KEY = "token";
    public static boolean isSdcardExit(){
      boolean sdCardExist = Environment.getExternalStorageState()
             .equals(android.os.Environment.MEDIA_MOUNTED);//判断sd卡是否存在
      return sdCardExist;
    }

    public static String getCachePath(){
     String sdcardPath = "/mnt/emmc";
        boolean is = isSdcardExit();
        Log.e("is"," isSdcardExit is "+is);
        if(is){
           File sdDir = Environment.getExternalStorageDirectory();//获取跟目录
           String path = sdDir.toString();
           sdcardPath = path + XXConfigData.CACHE_PATH;
       }else{
         sdcardPath = sdcardPath + XXConfigData.CACHE_PATH;
       }

       return sdcardPath;
    }


    public static void startLoginActivity(Activity act){
        Intent intent = new Intent("com.xiaxiang.xiawan.login");
        intent.setPackage(act.getPackageName());
        act.startActivityForResult(intent,XXConfigData.LOGIN_REQUEST_CODE);
    }
}
